home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Module Name: CASilenceDetect */
- /* */
- /* File Name: CASilenceDetect.c */
- /* */
- /* © Apple Computer, Inc. 1994-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1994-07-15 Jaakko Railo Original version */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "TextUtils.h"
-
- #ifndef __TELEPHONES__
- #include "Telephones.h"
- #endif
-
- #include "TestModule.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define rDisplaySilenceDetectDLOG 10000
- #define kSilenceDetectOnItem 2
- #define kSilenceDetectOffItem 3
- #define kSilencePeriodItem 5
- #define kSilenceDetectOn 1
- #define kSilenceDetectOff 0
-
- /****************************************** PROTOTYPES ******************************************/
-
- short DisplaySilenceDetect (long * silencePeriod);
- void DoTest (CHRSPtr paramPtr);
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- pascal short TestModule (CHRSPtr paramPtr)
- {
- short returnValue = noErr;
-
- if (paramPtr->version <= kTestModuleVersion) {
-
- DoTest (paramPtr);
-
- }
- else
- returnValue = kWrongVersion;
-
- return (returnValue);
- }
-
-
- short DisplaySilenceDetect (long * silencePeriod)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- short itemHit;
- DialogPtr theDialog;
- Str255 itemStr;
- long tlong;
-
- if ((theDialog = GetNewDialog (rDisplaySilenceDetectDLOG, nil, (WindowPtr)(-1L))) != nil) {
- GetDItem (theDialog, kSilencePeriodItem, &itemKind, &itemHand, &itemRect);
- SelIText (theDialog, kSilencePeriodItem, 0, 32767);
-
- ShowWindow (theDialog);
-
- ModalDialog (nil, &itemHit);
-
- if ((itemHit == kSilenceDetectOnItem) || (itemHit == kSilenceDetectOffItem)) {
- GetDItem (theDialog, kSilencePeriodItem, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *silencePeriod = tlong;
- }
-
- DisposeDialog (theDialog);
- }
- else
- itemHit = -1;
-
- return (itemHit);
- }
-
-
- void DoTest (CHRSPtr paramPtr)
- {
- TELHandle termHand = GetCurrentTELHandle (paramPtr);
- TELDNHandle dnHand;
- short numOfCAs;
- TELCAHandle caHand;
- short itemHit;
- OSErr errCode;
- Boolean silenceDetect;
- long silencePeriod;
-
- if ((dnHand = GetDNHandle (paramPtr)) != nil) {
-
- if ((numOfCAs = TELCountCAs (dnHand, telAllCallOrigins)) > 0) {
-
- if ((caHand = GetCAHandle (paramPtr)) != nil) {
- itemHit = DisplaySilenceDetect (&silencePeriod);
- if ((itemHit == kSilenceDetectOnItem) || (itemHit == kSilenceDetectOffItem)) {
-
- silenceDetect = (itemHit == kSilenceDetectOnItem)?kSilenceDetectOn:kSilenceDetectOff;
-
- if ((errCode = TELCASilenceDetect (caHand, silenceDetect, silencePeriod)) == noErr)
- Print (paramPtr, "TELCASilenceDetect --> SilenceDetect = %s",
- ((silenceDetect==kSilenceDetectOn)?"SilenceDetectOn":"SilenceDetectOff"));
- else
- Print (paramPtr, "### TELCASilenceDetect failed : %d", errCode);
- }
- else
- if (itemHit == -1)
- Print (paramPtr, "### Unable to get a DLOG resource");
- }
- else
- Print (paramPtr, "### Unable to retrieve the CA handle");
- }
- else
- Print (paramPtr, "### Number of CAs is %d", numOfCAs);
- }
- else
- Print (paramPtr, "### Unable to retrieve the DN handle");
- }
-
-
-